package com.yunlankeji.stemcells.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.model.request.Organization_goods;

import java.util.List;

public class Fragment_organization_goodsAdapter extends RecyclerView.Adapter<Fragment_organization_goodsAdapter.Fragment_organization_goodsViewHolder> {

    private List<Organization_goods>organization_goodsList;

    public Fragment_organization_goodsAdapter(List<Organization_goods> organization_goodsList) {
        this.organization_goodsList = organization_goodsList;
    }

    @NonNull
    @Override
    public Fragment_organization_goodsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_organization_goods,parent,false);
        Fragment_organization_goodsViewHolder fragment_organization_goodsViewHolder = new Fragment_organization_goodsViewHolder(itemview);
        return fragment_organization_goodsViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull Fragment_organization_goodsViewHolder holder, int position) {

        Organization_goods organization_goods = organization_goodsList.get(position);
        holder.tv_organization_goods_title.setText(organization_goods.getTv_organization_goods_title());
        holder.tv_organization_goods_price.setText(organization_goods.getTv_organization_goods_price());
        holder.iv_organization_goods.setImageResource(organization_goods.getIv_organization_goods());


    }

    @Override
    public int getItemCount() {
        return organization_goodsList.size();
    }

    class Fragment_organization_goodsViewHolder extends RecyclerView.ViewHolder{

        TextView tv_organization_goods_title;
        TextView tv_organization_goods_price;
        ImageView iv_organization_goods;

        public Fragment_organization_goodsViewHolder( View itemView) {
            super(itemView);
            this.tv_organization_goods_title = itemView.findViewById(R.id.tv_organization_goods_title);
            this.tv_organization_goods_price = itemView.findViewById(R.id.tv_organization_goods_price);
            this.iv_organization_goods = itemView.findViewById(R.id.iv_organization_goods);
        }
    }

}
